package com.bw.coupon.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.scripting.support.ResourceScriptSource;
import org.springframework.stereotype.Component;

@Configuration
public class luaConfig {

    @Bean(value = "lua-inventory-num")
    public DefaultRedisScript<Long> luaInventoryNum() {

        DefaultRedisScript<Long> defaultRedisScript = new DefaultRedisScript<>();

        defaultRedisScript.setScriptSource(new ResourceScriptSource(new ClassPathResource("lua/order1.lua")));

        defaultRedisScript.setResultType(Long.class);

        return defaultRedisScript;
    }
}